package com.lap.generator.domain.template.strategy;

import java.util.ArrayList;
import java.util.List;
import com.lap.generator.application.assembler.ModelTransformer;
import com.lap.generator.domain.TemplateModel;
import com.lap.generator.domain.template.CodeGenContext;
import com.lap.generator.domain.template.CodeTemplate;
import com.lap.generator.domain.valueobject.CodeType;

public class MessageGen implements CodeTemplate<String> {
  @Override
  public CodeType getType() {
    return CodeType.MESSAGE;
  }

  @Override
  public List<String> generate(CodeGenContext context) {
    TemplateModel model = ModelTransformer.transform(context.tableMeta(), context.envConfig());
    List<String> result = new ArrayList<>();
    model.getFields().stream().forEach(item -> result.addAll(item.getErrorMessages()));
    return result;
  }
}
